<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			function sortArrayByParityII(arr) {
				let result = [];
				let ji = 1;
				let ou = 0;
				for (let i = 0; i < arr.length; i++) {
					if (arr[i] % 2 == 0) {
						result[ou] = arr[i];
						ou += 2; //偶数下标移动
					} else {
						result[ji] = arr[i];
						ji += 2; //奇数下标移动
					}
				}
				return result;
			}
			console.log(sortArrayByParityII([4,2,5,7]));
		</script>
	</body>
</html>
